﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using SimpleGameData.GameObjects;
using Microsoft.Xna.Framework.Content.Pipeline;

namespace SimpleGameContentProcessors.GameObjects
{
    /// <summary>
    /// This class will be instantiated by the XNA Framework Content Pipeline
    /// to write the specified data type into binary .xnb format.
    ///
    /// This should be part of a Content Pipeline Extension Library project.
    /// </summary>
    [ContentTypeWriter]
    public class GameObjectDataWriter : ContentTypeWriter<GameObjectData>
    {
        protected override void Write(ContentWriter output, GameObjectData value)
        {
            output.Write(String.IsNullOrEmpty(value.TexturePath) ? String.Empty : value.TexturePath);
            output.Write(value.TintColor);
            output.Write(value.Rotation);
            output.Write(value.Scale);
            output.Write(value.Position);
            output.Write(value.Velocity);
        }

        public override string GetRuntimeReader(
                TargetPlatform targetPlatform)
        {
            return typeof(GameObjectDataReader).AssemblyQualifiedName;
        }
    }
}
